package com.zhentao.service.impl;

import com.zhentao.user.ChargeUserFeignApi;
import com.zhentao.market.ChargeMarketThreadUtils;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.common.enums.AppHttpCodeEnum;
import com.zhentao.model.pojo.user.ChargeUser;
import com.zhentao.service.ChargeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName: ChargeUserServiceImpl
 * @Author: 振涛教育_Q
 * @Date: 2024/12/22 20:37
 */
@Service
public class ChargeUserServiceImpl implements ChargeUserService {

    @Autowired
    private ChargeUserFeignApi userFeignApi;

    /**
     * @description  获取用户积分
     * @author 振涛教育_小Q
     * @date    2024/12/22 20:37
     * @param
     * @return com.zhentao.model.common.dtos.ResponseResult
     */
    @Override
    public ResponseResult getUserPoint() {
        // 获取当前登录用户
        ChargeUser user = ChargeMarketThreadUtils.getChargeUserThreadLocal();
        if(user == null) return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
        ResponseResult userPoint = userFeignApi.getUserPoint(user.getId());
        return ResponseResult.okResult(userPoint.getData());
    }
}
